import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @author 03010570
 * @date 2020/07/03
 * describe:    LeetCode: 589、N 叉树的前序遍历
 */
public class LeetCode_589 {

    public static void main(String[] args) {
        List<Node> list = new ArrayList<>();
        Node node1 = new Node(0, null);
        LeetCode_589 result = new LeetCode_589();
        result.preorder(node1);
    }


    private List<Integer> res;

    public  List<Integer> preorder(Node root) {
        res = new LinkedList<>();
        dfs(root);
        return res;
    }

    private void dfs(Node root) {
        if (root == null) return;
        res.add(root.val);
        for (Node child : root.children){
            dfs(child);
        }
    }
}
